package com.emagic.manage.mvp.subscribers;

import com.emagic.manage.mvp.views.LoadDataView;
import com.emagic.manage.mvp.views.ProgressView;

/**
 * TODO 描述该文件做什么
 *
 * @author baoy
 * @version 1.0
 *          Create by 2017/6/27 下午12:00
 */
public abstract class ProgressSubscriber<T> extends CommonErrorHandlerSubscriber<T> {

    public ProgressSubscriber(LoadDataView view) {
        super(view);
    }

    @Override
    public void onStart() {
        super.onStart();
        if (mLoadDataView instanceof ProgressView) {
            ((ProgressView) mLoadDataView).showProgress();
        }
    }

    @Override
    public void onCompleted() {

    }

    @Override
    public void onError(Throwable throwable) {
        super.onError(throwable);
        if (mLoadDataView instanceof ProgressView) {
            ((ProgressView) mLoadDataView).hideProgress();
        }
    }

    @Override
    public void onNext(T t) {
        if (mLoadDataView instanceof ProgressView) {
            ((ProgressView) mLoadDataView).hideProgress();
        }
    }
}
